/**
 * 
 */
package com.pmsco.pms.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.pmsco.pms.jsonutil.PmsCustomDateSerializer;
import com.pmsco.pms.jsonutil.PmsCustomRoleSerialize;

/**
 * @author Long Tran
 *
 */
@Entity
@Table(
	name = "PMS_USER", 
	uniqueConstraints = {
		@UniqueConstraint(columnNames = "USER_NAME"), 
		@UniqueConstraint(columnNames = "EMAIL_ADDR")
	}
)
public class PmsUser {
	private Long id;
	private String userName;
	private String password;
	private String firstName;
	private String lastName;
	private String midName;
	private String idNumber;
	private Date dob;
	private String homePhone;
	private String cellPhone;
	private String homeAddr;
	private String emailAddr;
	private String activated;
	private Date registerDate;
	private Date lastLogonDate;
	private Integer failLogonCount;
	private String locked;
	private PmsRole pmsRole;
	
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue
	@Column(name = "ID", nullable = false)
	public Long getId() {
		return id;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * @return the userName
	 */
	@Column(name = "USER_NAME", nullable = false)
	public String getUserName() {
		return userName;
	}
	
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	/**
	 * @return the password
	 */
	@Column(name = "PASSWORD", nullable = false)
	public String getPassword() {
		return password;
	}
	
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	/**
	 * @return the firstName
	 */
	@Column(name = "FIRST_NAME", nullable = false)
	public String getFirstName() {
		return firstName;
	}
	
	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	/**
	 * @return the lastName
	 */
	@Column(name = "LAST_NAME", nullable = false)
	public String getLastName() {
		return lastName;
	}
	
	/**
	 * @param lastName the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	/**
	 * @return the midName
	 */
	@Column(name = "MID_NAME", nullable = true)
	public String getMidName() {
		return midName;
	}
	
	/**
	 * @param midName the midName to set
	 */
	public void setMidName(String midName) {
		this.midName = midName;
	}
	
	/**
	 * @return the idNumber
	 */
	@Column(name = "ID_NUMBER", nullable = false)
	public String getIdNumber() {
		return idNumber;
	}
	
	/**
	 * @param idNumber the idNumber to set
	 */
	public void setIdNumber(String idNumber) {
		this.idNumber = idNumber;
	}
	
	/**
	 * @return the dob
	 */
	@Column(name = "DOB", nullable = false)
	@JsonSerialize(using = PmsCustomDateSerializer.class)
	public Date getDob() {
		return dob;
	}
	
	/**
	 * @param dob the dob to set
	 */
	public void setDob(Date dob) {
		this.dob = dob;
	}
	
	/**
	 * @return the homePhone
	 */
	@Column(name = "HOME_PHONE", nullable = true)
	public String getHomePhone() {
		return homePhone;
	}
	
	/**
	 * @param homePhone the homePhone to set
	 */
	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	}
	
	/**
	 * @return the cellPhone
	 */
	@Column(name = "CELL_PHONE", nullable = true)
	public String getCellPhone() {
		return cellPhone;
	}
	
	/**
	 * @param cellPhone the cellPhone to set
	 */
	public void setCellPhone(String cellPhone) {
		this.cellPhone = cellPhone;
	}
	
	/**
	 * @return the homeAddr
	 */
	@Column(name = "HOME_ADDR", nullable = false)
	public String getHomeAddr() {
		return homeAddr;
	}
	
	/**
	 * @param homeAddr the homeAddr to set
	 */
	public void setHomeAddr(String homeAddr) {
		this.homeAddr = homeAddr;
	}
	
	/**
	 * @return the emailAddr
	 */
	@Column(name = "EMAIL_ADDR", nullable = false)
	public String getEmailAddr() {
		return emailAddr;
	}
	
	/**
	 * @param emailAddr the emailAddr to set
	 */
	public void setEmailAddr(String emailAddr) {
		this.emailAddr = emailAddr;
	}
	
	/**
	 * @return the activated
	 */
	@Column(name = "ACTIVATED", nullable = true)
	public String getActivated() {
		return activated;
	}
	
	/**
	 * @param activated the activated to set
	 */
	public void setActivated(String activated) {
		this.activated = activated;
	}
	
	/**
	 * @return the registerDate
	 */
	@Column(name = "REGISTER_DATE", nullable = true)
	public Date getRegisterDate() {
		return registerDate;
	}
	
	/**
	 * @param registerDate the registerDate to set
	 */
	public void setRegisterDate(Date registerDate) {
		this.registerDate = registerDate;
	}
	
	/**
	 * @return the lastLogonDate
	 */
	@Column(name = "LAST_LOGON_DATE", nullable = true)
	public Date getLastLogonDate() {
		return lastLogonDate;
	}
	
	/**
	 * @param lastLogonDate the lastLogonDate to set
	 */
	public void setLastLogonDate(Date lastLogonDate) {
		this.lastLogonDate = lastLogonDate;
	}
	
	/**
	 * @return the failLogonCount
	 */
	@Column(name = "FAIL_LOGON_COUNT", nullable = true)
	public Integer getFailLogonCount() {
		return failLogonCount;
	}
	
	/**
	 * @param failLogonCount the failLogonCount to set
	 */
	public void setFailLogonCount(Integer failLogonCount) {
		this.failLogonCount = failLogonCount;
	}
	
	/**
	 * @return the locked
	 */
	@Column(name = "LOCKED", nullable = true)
	public String getLocked() {
		return locked;
	}
	
	/**
	 * @param locked the locked to set
	 */
	public void setLocked(String locked) {
		this.locked = locked;
	}
	
	/**
	 * @return the pmsRole
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PMS_ROLE_ID", nullable = false)
	@JsonSerialize(using = PmsCustomRoleSerialize.class)
	public PmsRole getPmsRole() {
		return pmsRole;
	}
	
	/**
	 * @param pmsRole the pmsRole to set
	 */
	public void setPmsRole(PmsRole pmsRole) {
		this.pmsRole = pmsRole;
	}
}
